<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>create (UsersController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File app/controllers/users_controller.rb, line 50</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
    <span class="ruby-ivar">@user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:user</span>])

    <span class="ruby-identifier">respond_to</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
      <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">save</span>
        <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'User was successfully created.'</span>
                <span class="ruby-comment cmt"># SonaliGoel: (Dec-20, 2008) Adding user to mywiki_users table</span>
                <span class="ruby-ivar">@wikiuser</span>=<span class="ruby-constant">MywikiUser</span>.<span class="ruby-identifier">new</span>
                <span class="ruby-ivar">@wikiuser</span>.<span class="ruby-identifier">id</span>=<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>
                <span class="ruby-ivar">@wikiuser</span>.<span class="ruby-identifier">user</span>=<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">username</span>
                <span class="ruby-ivar">@wikiuser</span>.<span class="ruby-identifier">save</span>
                <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@wikiuser</span>.<span class="ruby-identifier">save</span>
                        <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'User was successfully created.'</span>
                <span class="ruby-keyword kw">else</span> 
                        <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'User was successfully created. Could not add as mywiki user.'</span>
                <span class="ruby-keyword kw">end</span>           
        <span class="ruby-comment cmt">######redirect_to :action =&gt; 'index'  ######</span>
        <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">redirect_to</span>(<span class="ruby-ivar">@user</span>) }
        <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@user</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:created</span>, <span class="ruby-identifier">:location</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@user</span> }
      <span class="ruby-keyword kw">else</span>
        <span class="ruby-identifier">format</span>.<span class="ruby-identifier">html</span> { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;new&quot;</span> }
        <span class="ruby-identifier">format</span>.<span class="ruby-identifier">xml</span>  { <span class="ruby-identifier">render</span> <span class="ruby-identifier">:xml</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@user</span>.<span class="ruby-identifier">errors</span>, <span class="ruby-identifier">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">:unprocessable_entity</span> }
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>